Skip to content

Match escapable characters after a backslash without a regex - #480

Open
g4lb wants to merge 1 commit into
commonmark:mainfrom
g4lb:perf-backslash-escapable
Open

g4lb wants to merge 1 commit into
commonmark:mainfrom
g4lb:perf-backslash-escapable

Conversation

@g4lb

@g4lb g4lb commented Nov 25, 2026

Copy link
Copy Markdown

BackslashInlineParser uses a regex for the character after a backslash. This change uses an AsciiMatcher with the same 32 characters.

JMH, JDK 21, Apple M-series:

Input main this branch Change
Text with many escapes, parse 387 µs 296 µs −23.6%
Same text, parse and render 410 µs 326 µs −20.5%

No input of the 30 is slower. The output is the same on 2.1M inputs. Tests pass on JDK 17 and 21.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant